import 'package:dio/dio.dart';

class HttpError {
  static String getError(e) {
    if (e is DioException) {
      //dio错误
      if (e.type == DioExceptionType.connectionTimeout) {
        return "连接超时";
      } else if (e.type == DioExceptionType.sendTimeout) {
        return "请求超时";
      } else if (e.type == DioExceptionType.receiveTimeout) {
        return "响应超时";
      } else if (e.type == DioExceptionType.badResponse) {
        return "出现异常";
      } else if (e.type == DioExceptionType.cancel) {
        return "请求取消";
      } else if (e.type == DioExceptionType.badCertificate) {
        return "证书错误";
      } else if (e.type == DioExceptionType.connectionError) {
        return "连接错误";
      } else {
        return "未知错误";
      }
    } else {
      return "数据解析错误";
      //json解析错误
    }
  }
}
